﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TodayWhoModel;
using System.Data;

namespace TodayWho.adm
{
    public partial class notcontrolled : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["isAdmin"] != null)
            {
                if (Session["isAdmin"].ToString() == "True")
                {
                    DataTable dt = new DataTable();
                    dt.Load(UserModel.RetrieveUncontrolled());
                    gridViewUsers.DataSource = dt;
                    gridViewUsers.DataBind();
                }
                else
                {
                    Response.Redirect("default.aspx");
                }
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }

        protected void gridViewUsers_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView dw = (DataRowView)e.Row.DataItem;
                if (dw != null)
                {
                    HyperLink hyp = (HyperLink)e.Row.FindControl("hypPreview");
                    hyp.NavigateUrl = "preview.aspx?u=" + dw["username"].ToString(); 
                }
            }
        }
    }
}